Initial Questions to Explore


Setup

setwd("~/_code/colorado-dow/Phase I - Descriptive Analytics")

Load required libraries for wrangling data, charting, and mapping

library(plyr,quietly = T) # data wrangling
library(dplyr,quietly = T) # data wrangling
library(ggplot2, quietly = T) # charting
library(ggthemes,quietly = T) # so I can add the highcharts theme and palette
library(scales,quietly = T) # to load the percent function when labeling plots

Set our preferred charting theme

theme_set(theme_minimal()+theme_hc()+theme(legend.key.width = unit(1.5, "cm")))

Run script to get harvest data

source('~/_code/colorado-dow/datasets/Colorado Elk Harvest Data.R', echo=F)

Table of the harvest data

COElkRifleAll
source('~/_code/colorado-dow/datasets/Colorado GMUnit and Road data.R', echo=F)
## OGR data source with driver: ESRI Shapefile 
## Source: "/Users/psarnow/_code/colorado-dow/datasets/CPW_GMUBoundaries/BigGameGMUBoundaries03172015.shp", layer: "BigGameGMUBoundaries03172015"
## with 185 features
## It has 12 fields
## Integer64 fields read as strings:  GMUID 
## OGR data source with driver: ESRI Shapefile 
## Source: "/Users/psarnow/_code/colorado-dow/datasets/ne_10m_roads/ne_10m_roads.shp", layer: "ne_10m_roads"
## with 56601 features
## It has 29 fields
## Integer64 fields read as strings:  scalerank question

Take a peak at the boundary data

head(Unitboundaries2)

Harvest Ratio (Antlered vs Antlerless)

Statewide

# Group seasons
COElkHarvestRatioStatewide <- summarise(group_by(COElkRifleAll,Year,Unit),
                                        Antlered_Harvest = sum(Harvest.Antlered,na.rm = T),
                                        Antlerless_Harvest = sum(Harvest.Antlerless,na.rm = T),
                                        AntleredRatio = Antlered_Harvest / (Antlered_Harvest + Antlerless_Harvest))
# Group Units
COElkHarvestRatioStatewide <- summarise(group_by(COElkHarvestRatioStatewide,Year),
                                        AntleredRatio = mean(AntleredRatio,na.rm = T))

ggplot(COElkHarvestRatioStatewide, aes(Year,AntleredRatio)) +
  geom_bar(stat="identity",fill=ggthemes_data$hc$palettes$default[6]) +
  scale_y_continuous(labels = percent) +
  ylab("Percent Antlered") +
  coord_cartesian(ylim = c(.5,.7)) +
  labs(title="Statewide Elk Harvest Ratio", caption="source: cpw.state.co.us")

TODO - commentary


Harvest Ratio (Antlered vs Antlerless) by Unit

How the Harvest ratio is distributed across the state.

# Group seasons
COElkHarvestRatio <- summarise(group_by(COElkRifleAll,Year,Unit),
                               Antlered_Harvest = sum(Harvest.Antlered,na.rm = T),
                               Antlerless_Harvest = sum(Harvest.Antlerless,na.rm = T),
                               AntleredRatio = Antlered_Harvest / (Antlered_Harvest + Antlerless_Harvest))

Last year’s data

Year2017 <- filter(COElkHarvestRatio, Year == "2017")
HarvesttoPlot <- left_join(Unitboundaries2,Year2017, by=c("Unit"))
ggplot(HarvesttoPlot, aes(long, lat, group = group)) + 
  geom_polygon(aes(fill = AntleredRatio),colour = "grey50", size = .2) + #Unit boundaries
  geom_path(data = COroads,aes(x = long, y = lat, group = group), color="#3878C7",size=2) + #Roads
  geom_text(data=data_centroids,aes(x=longitude,y=latitude,label = Unit),size=3) + #Unit labels
  scale_fill_distiller(palette = "Reds",direction = 1,na.value = 'light grey',name='Percent Antlered') +
  xlab("") + ylab("") +
  labs(title="2017 Colorado Elk Harvest Ratio", caption="source: cpw.state.co.us")

TODO - commentary


Conclusion

TODO - commentary TODO - followup questions